<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="t" tagdir="/WEB-INF/tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<t:link />
<title>登录界面</title>
</head>

<style type="text/css">
.login {
	position: absolute;
	top: 50%;
	left: 50%;
	margin: -150px 0 0 -150px;
	width: 300px;
	height: 300px;
}

input {
	width: 100%;
	margin-bottom: 10px;
	background: rgba(0, 0, 0, 0.3);
	border: none;
	outline: none;
	padding: 10px;
	font-size: 13px;
	color: #fff;
	text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3);
	border: 1px solid rgba(0, 0, 0, 0.3);
	border-radius: 4px;
}

body {
	width: 100%;
	height: 100%;
	background: #2E8B57;
}

.btn {
	width: 100%;
	height: 40px;
	display: block;
	background: #66CDAA;
	border: 0;
}
</style>

<%
	String username = "";
	String password = "";
	//获取当前站点的所有Cookie
	Cookie[] cookies = request.getCookies();
	for (int i = 0; i < cookies.length; i++) {//对cookies中的数据进行遍历，找到用户名、密码的数据
		if ("cmsname".equals(cookies[i].getName())) {
			username = cookies[i].getValue();
		} else if ("cmspsss".equals(cookies[i].getName())) {
			password = cookies[i].getValue();
		}
	}
%>


<body>

	<div class="login">
		<div>
			<input type="text" id="username" name="username"
				placeholder="用户名" value="<%=username%>" required="required" />
		</div>
		<div>
			<input type="text" id="password" name="password" placeholder="密码"
				value="<%=password%>" required="required" />
		</div>
		<div>
			<tr>
				<td>是否记住密码:</td>
				<td><input type="checkbox" value="1" name="remember"
					id="remember" style="width: 30px;" checked="checked"></td>
			</tr>

		</div>
		<button id="submit" type="button" class="btn">登录</button>
	</div>
</body>


<script>
	$("#submit")
			.click(
					function() {
						$
								.ajax({
									url : "${pageContext.request.contextPath}/vaildata",
									type : 'POST',
									data : {
										username : $("#username").val(),
										password : $("#password").val(),
										flag : $("#remember").val()
									},
									success : function(data) {
										if (data == '1') {
											window.location.href = "${pageContext.request.contextPath}/index";
										}
									},
									error : function(data) {
										alert("用户名或密码错误!");
									}

								})
					})
</script>

</html>